package club.zhangliyuanblog.controller;

import club.zhangliyuanblog.service.PaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author liyuan.zhang
 * @date 2021/4/23 18:09
 */
@RestController
@RequestMapping(value = "/payment/hystrix")
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/ok/{id}")
    public String paymentOk(@PathVariable(value = "id") Integer id) {
        return paymentService.paymentOk(id);
    }

    @GetMapping("/timeout/{time}")
    public String timeout(@PathVariable(value = "time") Integer time) {
        return paymentService.timeout(time);
    }

    // ===========服务熔断
    @GetMapping("/circuit/{id}")
    public String pyamentCircuitBreaker(@PathVariable("id") Integer id) {
        return paymentService.paymentCircuitBreaker(id);
    }
}
